home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.024.Teach / teach.p / uUtils.inc.p < prev    next >
Encoding:
Text File  |  1990-06-24  |  2.3 KB  |  113 lines  |  [TEXT/MPS ]

  1. {**********************************************************************
  2. {*
  3. {* Teach uUtils -- Version 3.0  (implementation)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1990
  7. {* All Rights Reserved.
  8. {*
  9. {* Developer Technical Support Apple II Sample Code
  10. {*
  11. {* This file contains the code which implements  
  12. {* various utility routines used by the Teach program.
  13. {*
  14. {**********************************************************************}
  15. {$R-}
  16.  
  17. procedure    C1OutputToC1Input (TheHandle : handle); external;
  18. procedure    C1OutputToPString (TheHandle : handle); external;
  19.  
  20.  
  21.  
  22.  
  23. FUNCTION IntToString (i : Integer): STR255;
  24. var
  25.   size,
  26.   count  : Integer;
  27.   num : longInt;
  28.   str : string[20];
  29. BEGIN
  30.   num := i;
  31.   size := 0;
  32.   Long2Dec(num, @str, 19, true);
  33.   FOR count := 1 to 19 DO
  34.     BEGIN
  35.       IF (str[count] = '-') OR ((str[count] >= '0') AND (str[count] <= '9')) THEN
  36.         BEGIN
  37.           size := size + 1;
  38.           IntToString[size] := str[count];
  39.         END;
  40.     END;
  41.   IntToString[0] := char(size);
  42. END;
  43.  
  44. FUNCTION LongToString (l : LongInt): STR255; { test }
  45. var
  46.   size,
  47.   count  : Integer;
  48.   num : longInt;
  49.   str : string[20];
  50. BEGIN
  51.   num := l;
  52.   size := 0;
  53.   Long2Dec(num, @str, 19, true);
  54.   FOR count := 1 to 19 DO
  55.     BEGIN
  56.       IF (str[count] = '-') OR ((str[count] >= '0') AND (str[count] <= '9')) THEN
  57.         BEGIN
  58.           size := size + 1;
  59.           LongToString[size] := str[count];
  60.         END;
  61.     END;
  62.   LongToString[0] := char(size);
  63. END;
  64.  
  65.  
  66. FUNCTION IsToolError: BOOLEAN;
  67. BEGIN
  68.   IsToolError := FALSE;
  69.   if _ToolErr <> 0 then
  70.     IsToolError := TRUE;
  71. END;
  72.  
  73. PROCEDURE INC(VAR anIndex : Integer); {increase integer param by 1}
  74. BEGIN
  75.     anIndex := anIndex + 1;
  76. END;
  77.  
  78. PROCEDURE Dec(VAR anIndex: Integer); {decrease integer param by 1}
  79. BEGIN
  80.       anIndex := anIndex - 1;
  81. END;
  82.  
  83.  
  84.  
  85.  
  86.  
  87. {************************************************************************
  88. {*
  89. {* PStringToNewC1String
  90. {*
  91. {* This is a utility string that creates a C1Input string in a handle
  92. {* using a PString as input.
  93. {*
  94. {************************************************************************}
  95. function   PStringToNewC1String   (PStringPtr : String255Ptr) : handle;
  96.  
  97.     var
  98.         TheNewHandle : handle;
  99.         Size : integer;
  100.  
  101. begin
  102.     Size := length(PStringPtr^);
  103.     TheNewHandle := NewHandle(2+size,userID,0,NIL);
  104.     
  105.     BlockMove(@PStringPtr^[1],ptr(2+LongInt(TheNewHandle^)),size);
  106.     
  107.     integer(TheNewHandle^^) := size;
  108.     
  109.     PStringToNewC1String := TheNewHandle;
  110. end;
  111.  
  112.  
  113.